package Demo1;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/1/17
 * Time:15:30
 **/
interface IFlying {
    void fly();
}
interface IRunning {
    void run();
}
interface ISwimming {
    void swim();
}

class Cat extends Animal implements IRunning{

    public Cat(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println(this.name+"正在跑");
    }
}
class Fish extends Animal implements ISwimming{

    public Fish(String name) {
        super(name);
    }

    @Override
    public void swim() {
        System.out.println(this.name+"游泳");
    }
}
class Duck extends Animal implements IRunning, ISwimming, IFlying{

    public Duck(String name) {
        super(name);
    }

    @Override
    public void fly() {
        System.out.println(this.name+"正在飞");
    }

    @Override
    public void run() {
        System.out.println(this.name+"正在跑");
    }

    @Override
    public void swim() {
        System.out.println(this.name+"正在游泳");
    }
}
class Animal{
    protected String name;

    public Animal (String name){
        this.name = name;
    }
}

public class TestDemo1 {
    public static void main(String[] args) {
        IRunning iRunning = new Duck("yaya");
        iRunning.run();
        ISwimming iSwimming = new Duck ("yaya");
        iSwimming.swim();
        IFlying iFlying = new Duck ("yaya");
        iFlying.fly();
    }
}
